/** UVa 230 - Borrowers */

#include<bits/stdc++.h>
using namespace std;

struct book {
  string title;
  string author;
  bool borrowed;
  book(string t, string a, bool b):title(t), author(a), borrowed(b){};
};

struct Comp {
  bool operator() (book a, book b) {
    if(a.author==b.author) return a.title < b.title;
    else return a.author < b.author;
  }
};

set<book, Comp> stock;

bool readstock() {
  string buf;
  getline(cin,buf); // No '\n' included.
  if(buf == "END")return false;

  stock.emplace(buf.substr(1,buf.rfind('"')-1),
      buf.substr(buf.find(" by ")+sizeof(" by ")-1),
      false);
  return true;
}

bool query() {
  string op;cin>>op;
  if(op == "BORROW") {
      string tt;cin>>tt;
      tt = tt.substr(1, tt.size()-1);
      
  }
}

void solve() {
  while(readstock())continue;
  while(query())continue;
  return;
}
int main() {
  freopen("tc/in.txt", "r", stdin);
  solve();
  return 0;
}
